package siyuan.run.nacos.security.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * @Classname SwaggerConfig
 * @Description TODO
 * @Date 2020/6/30 21:04
 * @Created by wuzhiqian
 */
@Configuration
@EnableKnife4j
@EnableSwagger2
public class SwaggerConfig {

    @Value("${server.port}")
    private String port;

    @Bean(value = "nacosSecurity")
    public Docket nacosSecurity() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                //分组名称
                .groupName("nacos security")
                .select()
                //这里指定Controller扫描包路径(项目路径也行)
                .apis(RequestHandlerSelectors.basePackage("siyuan.run.nacos.security.controller"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("nacos security")
                .description("nacos security")
                .termsOfServiceUrl("http://localhost:"+port)
                .version("master")
                .build();
    }
}